package com.itheima.config;

import com.itheima.interceptor.Myinterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author zhouwei
 * @date 2020-01-13 10:47
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {
    //注册拦截器
    public Myinterceptor myinterceptor(){
        return new Myinterceptor();
    }

    //添加拦截器到拦截器链
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myinterceptor()).addPathPatterns("/*");
    }
}
